//strgst1.cpp -- applying the STL to a string
#include<iostream>
#include<string>
#include<algorithm>

int main()
{
	using namespace std;
	string letters;

	cout<<"Enter the letter grouping(quit to quit):";
	while(cin>>letters && letters!="quit")
	{
		cout<<"permutations of"<<letters<<endl;
		sort(letters.begin(),letters.end());
		cout<<letters<<endl;
		while(next_permutation(letters.begin(),letters.end()))
			cout<<letters<<endl;
		cout<<"enter next sequence(quit to quit)";
	}
	cout<<"done.\n";
	return 0;
}